package com.zyong.design.pattern.state.case2;

/**
 * 发放奖品的状态
 * @author zyong
 */
public class DistributeAbstractState extends AbstractState {
    Activity activity;

    public DistributeAbstractState(Activity activity) {
        this.activity = activity;
    }

    @Override
    public void deductingPoints() {
        System.out.println("不能扣除积分");
    }

    @Override
    public boolean raffle() {
        System.out.println("不能抽奖");
        return false;
    }

    /**
     * 发放奖品
     */
    @Override
    public void distributePrizes() {
        if (activity.getCount() > 0) {
            System.out.println("恭喜中奖了");
            // 改变状态为不能抽奖
            activity.setState(activity.getNoRaffleState());
        } else {
            System.out.println("很遗憾，奖品发放完了");
            // 改变状态为奖品发放完毕
            activity.setState(activity.getDistributeOutState());
        }
    }
}
